package com.alfayun.fiscalriskanalysis.another.specification.analysis;

import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import com.alfayun.fiscalriskanalysis.another.analysis.Analysis;
import com.alfayun.fiscalriskanalysis.another.indicator.Indicator;
import com.alfayun.fiscalriskanalysis.another.report.Report;
import com.alfayun.fiscalriskanalysis.another.specification.indicator.IndicatorSpec;

public final class AnalysisSpec {

	private List<IndicatorSpec> indicators;

	private String id;
	private String name;
	private Set<String> tags;

	public AnalysisSpec(String id, String name, List<IndicatorSpec> indicators, Set<String> tags) {
		this.id = id;
		this.name = name;
		this.indicators = indicators;
		this.tags = tags;
	}

	public Analysis analyse(Collection<Report> reports, LocalDate startDate, LocalDate endDate) {
		return new Analysis(this, reports, startDate, endDate);
	}

	public List<Indicator> buildIndicators() {
		return indicators.stream().map(this::buildIndicator).collect(Collectors.toList());
	}

	private Indicator buildIndicator(IndicatorSpec spec) {
		return new Indicator(spec);
	}

}
